const { merge } = require('webpack-merge')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const base = require('./build/webpack.base.config')
const { locales } = require('./locales')
const htmlPlugins = require('./build/utils')
const { isDevelopment } = require('./utils')
if (isDevelopment) {
  module.exports = [
    Object.keys(locales).map((lang, i) => ({
      ...merge(base, {
        plugins: htmlPlugins(lang, i)
      })
    })),
    require('./build/webpack.dev.config')
  ]
} else {
  const plugins = [
    new CleanWebpackPlugin({
      protectWebpackAssets: true
    })
  ]
  module.exports = Object.keys(locales).map((lang, i) => ({
    ...merge(base, require('./build/webpack.prod.config'), {
      plugins: htmlPlugins(lang).concat(i === 0 ? plugins : [])
    })
  }))
}
